package com.diaohaiwen.basic.websockt.obj.dto;

import com.alibaba.fastjson.JSONObject;
import com.diaohaiwen.basic.websockt.obj.model.Notice;
import com.diaohaiwen.common.enums.NoticeEnum;
import lombok.Data;

/**
 * 消息通知-文字
 *
 * @author 刁海文
 * @since 2023/12/7 22:43
 */
@Data
public class TextDto {

    /**
     * 接受者ID
     */
    private String receiverId;
    /**
     * 接受者的名称
     */
    private String receiverName;
    /**
     * 发送内容
     */
    private String contents;
    /**
     * 是否为群组
     */
    private Boolean group;

    public Notice toNotice() {
        Notice notice = new Notice();
        notice.setContents(JSONObject.toJSONString(contents))
                .setReceiverId(receiverId)
                .setReceiverName(receiverName)
                .setGroup(group)
                .setNoticeType(NoticeEnum.TEXT);
        return notice;
    }
}
